package com.wish.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wish.dto.TsfContractDto;
import com.wish.entity.TCwPaymentPlan;
import com.wish.entity.TSfContract;
import com.wish.service.ITCwPaymentPlanService;
import com.wish.service.ITSfContractService;
import com.wish.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 五组
 * @since 2021-04-08
 */
@RestController
@RequestMapping("/wish/t-sf-contract")
public class TSfContractController {

    @Autowired
    private ITSfContractService sfContractService;

    @Autowired
    private ITCwPaymentPlanService cwPaymentPlanService;

    @RequestMapping("/contracts")
    public ResultEntity contracts(TsfContractDto tsfContractDto){
        PageHelper.startPage(tsfContractDto.getPageNum(),tsfContractDto.getPageSize());
        List<TSfContract> list = sfContractService.contracts(tsfContractDto);
        PageInfo<TSfContract> info = new PageInfo<>(list);
        return ResultEntity.ok(info);
    }

    @RequestMapping("/getOne")
    public TSfContract getOne(Integer id){
        TSfContract tSfContract = cwPaymentPlanService.getPlans(id);
        return tSfContract;
    }

}
